package cn.dnui_xqh414.dnuifood_16110100414.model;

import java.util.List;

import cn.dnui_xqh414.dnuifood_16110100414.bean.GetAllCollectBean;
import cn.dnui_xqh414.dnuifood_16110100414.bean.RegisterBean;
import cn.dnui_xqh414.dnuifood_16110100414.bean.Userbean;
import cn.dnui_xqh414.dnuifood_16110100414.iface.SearchIface;
import cn.dnui_xqh414.dnuifood_16110100414.iface.UserIface;
import cn.dnui_xqh414.dnuifood_16110100414.listener.OnRetrofitListener;
import cn.dnui_xqh414.dnuifood_16110100414.service.Searchservice;
import cn.dnui_xqh414.dnuifood_16110100414.service.UserService;
import retrofit2.Call;


public class UserModel extends BaseModel
        implements UserIface,SearchIface {

    private UserService service;
    private Searchservice searchservice;

    public UserModel(){
        super();
        service = retrofit.create(UserService.class);
        searchservice = retrofit.create(Searchservice.class);
    }


    @Override
    public void login(String username,
                      String userpass,
                      final OnRetrofitListener listener) {
        Call<Userbean> call =
                service.doLogin(username, userpass);
        bindCallBack(call,listener,1);
    }

    @Override
    public void register(String username, String userpass,
                         String mobilenum, String address,
                         String comment, final OnRetrofitListener listener) {

        Call<RegisterBean> call =
                service.doRegister(username,userpass, mobilenum, address, comment);
        bindCallBack(call,listener,2);
    }

    @Override
    public void getSearch(String keyword, OnRetrofitListener listener) {
        Call call = searchservice.getSearch(keyword);
        bindCallBack(call,listener,3);
    }

    @Override
    public void getUser(int userId, OnRetrofitListener listener) {
        Call call = service.getUser(userId);
        bindCallBack(call,listener,4);
    }

    @Override
    public void JustBuyIt(int userId, int foodId, int num, int sum,
                          String time, String address, OnRetrofitListener listener) {
        Call call = service.JustBuyIt(userId,foodId,num,sum,time,address);
        bindCallBack(call,listener,5);
    }

    @Override
    public void UpdateUser(int UserId, String username, String userpass, String mobilenum,
                           String address, OnRetrofitListener listener) {
        Call call = service.UpdateUser(UserId,username,userpass,mobilenum,address);
        bindCallBack(call,listener,6);
    }

    @Override
    public void insertComment(int item_id, String content, OnRetrofitListener listener) {
        Call call = service.insertComment(item_id,content);
        bindCallBack(call,listener,7);
    }

    @Override
    public void getAllOrder(int UserID, OnRetrofitListener listener) {
        Call call = service.getAllOrder(UserID);
        bindCallBack(call,listener,8);
    }

}
